﻿/*
   Open Intel 
   Copyright © 2011 – ISC. All Rights Reserved.
*/

using Caliburn.Micro;
using System.ComponentModel.Composition;

namespace OI.ViewModels
{
    [Export(typeof(MessageBoxViewModel))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class MessageBoxViewModel : Screen
    {
        [ImportingConstructor]
        public MessageBoxViewModel()
            : base()
        {
        }

        public bool IsVisible
        {
            get { return !string.IsNullOrWhiteSpace(Message); }
        }

        public string Message 
        {
            get { return _Message; }
            set
            {
                if (string.IsNullOrWhiteSpace(_Message) || string.IsNullOrWhiteSpace(value))
                {
                    _Message = value;
                }
                else
                {
                    _Message = value + "\r\n" + _Message;
                }
                RaisePropertyChangedEventImmediately("Message");
                RaisePropertyChangedEventImmediately("IsVisible");
            }
        }
        private string _Message;

        public void Ok()
        {
            Message = null;
        }
    }
}